<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>优惠开单</title>
    <meta name="viewport" content="width=100%, initial-scale=1.0, user-scalable=no" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="stylesheet" href="lib/weix/style/weui.min.css">
    <link rel="stylesheet" href="css/fonts.css">
    <link rel="stylesheet" href="css/comm.css">
    <link rel="stylesheet" href="css/form_hej.css">
    <style>
        .weui-gallery{ display:block !important; visibility:hidden; opacity:0;}
        .weui-gallery.on{ visibility:visible; opacity:1}
    </style>
</head>

<body>
<div class="weui-cells">
    <a class="weui-cell weui-cell_access" href="form_report.html">
        <div class="weui-cell__hd" style="width:45px;"><i class="icon-customer"></i></div>
        <div class="weui-cell__bd">
            <p>选择已报备客户</p>
        </div>
        <div class="weui-cell__ft"></div>
    </a>
</div>

<div class="weui-cells weui-cells_form">
    <div class="weui-cell">
        <div class="weui-cell__hd"><label class="weui-label">成交额</label></div>
        <div class="weui-cell__bd">
            <input class="weui-input" type="number" placeholder="请输入成交额" id="J_chj">
        </div>
    </div>
    <div class="weui-cell">
        <div class="weui-cell__hd"><label class="weui-label">分成积分</label></div>
        <div class="weui-cell__bd">
            <input class="weui-input" type="tel" placeholder="请输入一级合伙人所得积分" id="J_jif" maxlength="10">
        </div>
    </div>

</div>

<!--<div class="weui-cells weui-cells_form">
    <div class="weui-cell">
        <div class="weui-cell__bd">
            <div class="weui-uploader">
                <div class="weui-uploader__hd">
                    <p class="weui-uploader__title">上传凭证</p>
                    <div class="weui-uploader__info">最多5张图片</div>
                </div>
                <div class="weui-uploader__bd">
                    <ul class="weui-uploader__files" id="uploaderFiles">
                        <li class="weui-uploader__file" style="background-image:url(images/pic_160.png)"></li>
                        <li class="weui-uploader__file weui-uploader__file_status" style="background-image:url(images/pic_160.png)">
                            <div class="weui-uploader__file-content">
                                <i class="weui-icon-warn"></i>
                            </div>
                        </li>
                        <li class="weui-uploader__file weui-uploader__file_status" style="background-image:url(images/pic_160.png)">
                            <div class="weui-uploader__file-content">50%</div>
                        </li>
                    </ul>
                    <div class="weui-uploader__input-box">
                        <input id="uploaderInput" class="weui-uploader__input" type="file" accept="image/*" multiple>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
-->

<div class="weui-cells weui-cells_form" id="uploader">
    <div class="weui-cell">
        <div class="weui-cell__bd">
            <div class="weui-uploader">
                <div class="weui-uploader__hd">
                    <p class="weui-uploader__title">上传凭证</p>
                    <div class="weui-uploader__info"><span id="uploadCount">0</span>/5</div>
                </div>
                <div class="weui-uploader__bd">
                    <ul class="weui-uploader__files" id="uploaderFiles"></ul>
                    <div class="weui-uploader__input-box">
                        <input id="uploaderInput" class="weui-uploader__input" type="file" accept="image/*" capture="camera" multiple />
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<div class="weui-btn-area">
    <a class="weui-btn weui-btn_primary" href="javascript:" id="J_qued">确定</a>
</div>




<!--<div class="weui-gallery" id="gallery">
    <span class="weui-gallery__img" id="galleryImg" style="background-image:url()"></span>
    <div class="weui-gallery__opr">
        <a href="javascript:" class="weui-gallery__del" id="J_clo_img">
            <i class="weui-icon-delete weui-icon_gallery-delete"></i>
        </a>
    </div>
</div>-->



<script src="/js/zepto.min.js"></script>
<script src="https://res.wx.qq.com/open/libs/weuijs/1.0.0/weui.min.js"></script>
<script src="/js/comm.js"></script>
<script type="text/javascript">
    $(function(){
        sessionStorage.setItem("need-refresh", true);  //返回上一页刷新

        //-----------------------------------------------------------------------
        //上传图片
//	var tmpl = '<li class="weui-uploader__file" style="background-image:url(#url#)"></li>',
//		$gallery = $("#gallery"),
//		$galleryImg = $("#galleryImg"),
//		$uploaderInput = $("#uploaderInput"),
//		$uploaderFiles = $("#uploaderFiles");
//
//	$uploaderInput.on("change", function(e){
//		var src, url = window.URL || window.webkitURL || window.mozURL, files = e.target.files;
//		for (var i = 0, len = files.length; i < len; ++i) {
//			var file = files[i];
//
//			if (url) {
//				src = url.createObjectURL(file);
//			} else {
//				src = e.target.result;
//			}
//
//			$uploaderFiles.append($(tmpl.replace('#url#', src)));
//		}
//	});
//	var $this_img = [];
//	$uploaderFiles.on("click", "li", function(){
//		//$galleryImg.attr("style", this.getAttribute("style"));
//		$this_img = $(this)
//		$galleryImg.css('background-image','url('+$(this).css("backgroundImage").replace('url(','').replace(')','')+')')
//		$gallery.addClass('on')
//		//$gallery.fadeIn(100);
//	});
//	$galleryImg.on("click", function(){
//		//$gallery.fadeOut(100);
//		$gallery.removeClass('on')
//	});
//	$(document).on('click','#J_clo_img',function(){
//		$this_img.hide();
//		$gallery.removeClass('on')
//	})


        var uploadCount = 0;
        weui.uploader('#uploader', {
            url: '/upload/uploadFile',
            auto: true,
            type: 'file',
            fileVal: 'photo',
            compress: {
                width: 1600,
                height: 1600,
                quality: .8
            },
            onBeforeQueued: function(files) {
                // `this` 是轮询到的文件, `files` 是所有文件

                if(["image/jpg", "image/jpeg", "image/png", "image/gif"].indexOf(this.type) < 0){
                    weui.alert('请上传图片');
                    return false; // 阻止文件添加
                }
                if(this.size > 10 * 1024 * 1024){
                    weui.alert('请上传不超过10M的图片');
                    return false;
                }
                if (files.length > 5) { // 防止一下子选择过多文件
                    weui.alert('最多只能上传5张图片，请重新选择');
                    return false;
                }
                if (uploadCount + 1 > 5) {
                    weui.alert('最多只能上传5张图片');
                    return false;
                }

                ++uploadCount;

                // return true; // 阻止默认行为，不插入预览图的框架
            },
            onQueued: function(){
                console.log(this);

                // console.log(this.status); // 文件的状态：'ready', 'progress', 'success', 'fail'
                // console.log(this.base64); // 如果是base64上传，file.base64可以获得文件的base64

                // this.upload(); // 如果是手动上传，这里可以通过调用upload来实现；也可以用它来实现重传。
                // this.stop(); // 中断上传

                // return true; // 阻止默认行为，不显示预览图的图像
            },
            onBeforeSend: function(data, headers){
                console.log(this, data, headers);
                // $.extend(data, { test: 1 }); // 可以扩展此对象来控制上传参数
                // $.extend(headers, { Origin: 'http://127.0.0.1' }); // 可以扩展此对象来控制上传头部

                // return false; // 阻止文件上传
            },
            onProgress: function(procent){
                console.log(this, procent);
                // return true; // 阻止默认行为，不使用默认的进度显示
            },
            onSuccess: function (ret) {
                console.log(this, ret);
                // return true; // 阻止默认行为，不使用默认的成功态
            },
            onError: function(err){
                console.log(this, err);
                // return true; // 阻止默认行为，不使用默认的失败态
            }
        });

        //-----------------------------------------------------------------------
        //提交操作
        $(document).on('click','#J_qued',function(){
            var tel_data = $('#J_tel').val().trim();
            var date_data = $('#J_date').val().trim();
            var name_data = $('#J_name').val().trim();
            var diz_data = $('#J_diz').val().trim();

            if(!name(name_data)){
                return false
            }

            if(!tel(tel_data)){
                return false
            }

            if(diz_data.trim() == ''){
                weui.topTips('请填写正确的楼盘信息');
                return false
            }

            if(date_data.trim() == ''){
                weui.topTips('请填写预计到店时间');
                return false
            }

            var loading = weui.loading('数据提交中', {
                className: 'custom-classname'
            });

            setTimeout(function () {
                loading.hide();
                weui.toast('提交成功', {
                    duration: 1500,
                    className: 'custom-classname',
                    callback: function(){
                        location.replace('code.html')
                    }
                });
            }, 1000);


        })

    });
</script>
</body>
</html
